/**
 * 
 */
package hawk.example.juni5.testkit;

import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
import static org.junit.platform.testkit.engine.EventConditions.event;
import static org.junit.platform.testkit.engine.EventConditions.finishedWithFailure;
import static org.junit.platform.testkit.engine.EventConditions.test;
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.instanceOf;
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.message;

import org.junit.jupiter.api.Test;
import org.junit.platform.testkit.engine.EngineTestKit;

public class EngineTestKitFailedMethodDemo {

	@Test
	void verifyJupiterMethodFailed() {
		EngineTestKit.engine("junit-jupiter") // Select the JUnit Jupiter TestEngine.
				.selectors(selectClass(ExampleTestCase.class)) // Select the ExampleTestCase test class.
				.execute() // Execute the TestPlan
				.testEvents() // Filter by test events
				.assertThatEvents() // Assert that the recorded test events contain exactly one failing test named failingTest with an
									// exception of type ArithmeticException and an error message equal to "/ by zero".
				.haveExactly(1, event(test("failingTest"), finishedWithFailure(instanceOf(ArithmeticException.class), message("/ by zero"))));

	}

}
